﻿#ifndef DASETTING_H
#define DASETTING_H

#include "qobject.h"
#include "qobjectdefs.h"
#include "qsize.h"
#include "qvariant.h"
#include <QWidget>
#include <QSettings>
#include <QMap>

#define GENERAL_NAME        "General/name"
#define GENERAL_VERSION     "General/version"
#define GENERAL_SIZE        "General/size"
#define GENERAL_POSITION    "General/positon"
#define GENERAL_DATEFORMAT  "General/date-format"

#define HLD_TITLE           "holiday/title"
#define HLD_DATE            "holiday/date"

using ConfigType = QMap<QString,QVariant>;

class DASetting : public QObject
{
    Q_OBJECT
    
    
    
public:
    explicit DASetting(QObject *parent = nullptr);

    int GetNumberValue(const QString &key);
    QString GetStringValue(const QString &key);
    QSize GetSizeValue(const QString &key);
    QPoint GetPointValue(const QString &key);
    QDateTime GetDateValue(const QString &key);
    
    void SetValue(const QString &key, const QVariant &var);
    
public slots:
    void SaveConfig();
    
private:
    void Init();
    void Default();
    
private:
    ConfigType DefaultConf;
    QSettings *settings;
};

#endif // DASETTING_H